package cn.signalpha.modules.shop.entity;

import cn.signalpha.core.swagger.ApiModelPropertyEnum;
import cn.signalpha.modules.pay.enums.PayTypeEnum;
import cn.signalpha.modules.shop.entity.enums.LogisticsTypeEnum;
import cn.signalpha.modules.shop.entity.enums.OrderTypeEnum;
import cn.signalpha.modules.shop.vo.OrderLogisticsVO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 订单实体类
 *
 * @author suguangjun
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("shop_order")
@ApiModel(value = "Order对象", description = "订单")
public class Order implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "订单id")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
	@JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty(value = "商户id")
    private Long sellerId;

    @ApiModelProperty(value = "用户id")
    private Long userId;

    @ApiModelProperty(value = "订单编号")
    private String orderNo;

    @ApiModelProperty(value = "支付状态：0未支付 1已支付")
    private Integer payStatus;

    @ApiModelProperty(value = "支付类型")
	@ApiModelPropertyEnum(PayTypeEnum.class)
    private String payType;

    @ApiModelProperty(value = "订单状态：-1取消交易 0待付款 1待发货 2待签收 3已完成")
    private Integer orderStatus;

	@ApiModelProperty(value = "结算状态：0未结算 1已结算 此结算状态不代表结算单真实结算状态")
	private Integer settleStatus;

	@ApiModelProperty(value = "售后状态：0无售后（明细没有处理中状态） 1有售后（明细有处理中状态） 2全售后（明细全部退款完）")
	private Integer refundStatus;

	@ApiModelProperty(value = "评价状态：0未评价 1已评价")
	private Integer commentStatus;

	@ApiModelProperty(value = "开票状态：0未开票 1已开票")
	private Integer receiptStatus;

    @ApiModelProperty(value = "订单类型")
	@ApiModelPropertyEnum(OrderTypeEnum.class)
    private Integer orderType;

    @ApiModelProperty(value = "实际支付")
    private Double orderPrice;

    @ApiModelProperty(value = "商品总价")
    private Double goodsPrice;

    @ApiModelProperty(value = "商品名称")
    private String goodsName;

    @ApiModelProperty(value = "商品数量")
    private Integer goodsNum;

	@ApiModelProperty(value = "余额抵扣")
	private Double deductMoney;

	@ApiModelProperty(value = "积分抵扣")
	private Double deductIntegral;

	@ApiModelProperty(value = "积分金额")
	private Double deductIntegralMoney;

	@ApiModelProperty(value = "商户优惠券抵扣")
	private Double deductCouponSeller;

	@ApiModelProperty(value = "平台优惠券抵扣")
	private Double deductCouponSystem;

	@ApiModelProperty(value = "营销活动抵扣金额")
	private Double deductPublicity;

	@ApiModelProperty(value = "营销活动抵扣详情")
	private String deductPublicityDetail;

	@ApiModelProperty(value = "运费")
	private Double logisticsFee;

	@ApiModelProperty(value = "物流类型")
	@ApiModelPropertyEnum(LogisticsTypeEnum.class)
	private Integer logisticsType;

	@ApiModelProperty(value = "收货信息")
	@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
	private String logisticsInfo;

	@ApiModelProperty(value = "商家自提信息")
	@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
	private String logisticsSellerInfo;

	@ApiModelProperty(value = "同城配送信息")
	@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
	private String logisticsDeliveryInfo;

	@ApiModelProperty(value = "买家留言")
	private String buyerRemark;

	@ApiModelProperty(value = "卖家备注")
	private String sellerRemark;

	@ApiModelProperty(value = "订单备注")
	private String remark;

    @ApiModelProperty(value = "下单时间")
    private Date createTime;

	@ApiModelProperty(value = "支付时间")
	private Date payTime;

    @ApiModelProperty(value = "发货时间")
    private Date sendTime;

    @ApiModelProperty(value = "完成时间")
    private Date finishTime;

	@ApiModelProperty(value = "结算时间")
	private Date settleTime;

    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    @TableField(exist = false)
	@ApiModelProperty(value = "订单商品列表")
    private List<OrderDetail> orderDetailList;

	@TableField(exist = false)
	@ApiModelProperty(value = "订单物流列表")
	private List<OrderLogisticsVO> orderLogisticsList;

}
